import java.util.Date;


public class CommuteRecord {

	String regionName;
	Date inDate;
	Date outDate;
	TimeSheet amount;
	TimeSheet regionTotal;
	
	public CommuteRecord(String regionName, Date inDate, Date outDate, TimeSheet amount, TimeSheet total) {
		this.regionName = regionName;
		this.inDate = inDate;
		this.outDate = outDate;
		this.amount = amount;
		this.regionTotal = total;
	}
	
	public CommuteRecord(String regionName, Date inDate) {
		this(regionName, inDate, null, new TimeSheet(), new TimeSheet());
	}
	
	public CommuteRecord(String regionName, Date inDate, Date outDate) {
		this(regionName, inDate, outDate, new TimeSheet(), new TimeSheet());
	}
	
	public CommuteRecord(CommuteRecord other) {
		this(new String(other.regionName),
				new Date(other.inDate.getTime()),
				new Date(other.outDate.getTime()),
				new TimeSheet(other.amount),
				new TimeSheet()
				);
	}
	
	public void calcAmount() {
		if( this.inDate != null && this.outDate != null ) {
			this.amount = TimeSheet.interval(inDate, outDate);
		
			/*if(exTotal == null) {
				this.regionTotal = new TimeSheet(this.amount);
			} else {
				this.regionTotal = Utility.sum(this.amount, exTotal);
			}*/
		}
	}
	
	public boolean equals(CommuteRecord other) {
		// TODO Auto-generated method stub
		boolean ret = false;
		if( this.regionName.compareTo(other.regionName) == 0 
				&& this.inDate.getTime() == other.inDate.getTime() 
				&& this.outDate.getTime() == other.outDate.getTime() ) {
			ret = true;
		}
		
		return ret;
	}
	
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return  "rN : " + this.regionName +
				", i : " + this.inDate +
				", o : " + this.outDate +
				", a : " + this.amount +
				", rT : " + this.regionTotal;
	}
	

	
	public String getRegionName() {
		return regionName;
	}
	
	public void setRegionName(String regionName) {
		this.regionName = regionName;
	}
	
	public Date getInDate() {
		return inDate;
	}

	public void setInDate(Date inDate) {
		this.inDate = inDate;
	}

	public Date getOutDate() {
		return outDate;
	}

	public void setOutDate(Date outDate) {
		this.outDate = outDate;
	}

	public TimeSheet getAmount() {
		return amount;
	}

	public void setAmount(TimeSheet amount) {
		this.amount = amount;
	}

	public TimeSheet getTotal() {
		return regionTotal;
	}

	public void setTotal(TimeSheet total) {
		this.regionTotal = total;
	}

}
